﻿@model IEnumerable<AceMobile.Models.Tablets.Tablet>
@functions{
    string trimString(string str, int leng){
        if ((str.Length > 10)&&(leng < str.Length))
        {
            return str.Substring(0, leng) + "...";
        }
        else
        {
            return str;
        }        
    }
}
@{
    ViewBag.Title = "Index";    
}

<link href="@Url.Content("~/Content/TableStyle.css")" rel="stylesheet"  type="text/css" />     

        <h2>Quản lý máy tính bảng đang trong cơ sở dữ liệu</h2>
        @Html.ActionLink("Quản lý hệ điều hành", "Index", "TabletOSAdmin",null, new { style = "font-weight: bold; color: #ff6a00; display: inline; float: right" }) 
        @Html.ActionLink("Quản lý nhà sản xuất", "Index", "TabletProducerAdmin",null, new { style="font-weight: bold; color: #ff6a00; display: inline; float: right; margin-right: 20px" })

        <style>
            #createnew a:hover
            {
                color: black;
            }
        </style>
        <p id="createnew">
            @Html.ActionLink("Tạo mới", "Create")
            
        </p>        
        <table>
            <tr>
                <th>
                    @Html.LabelFor(a => Model.First().Name)
                </th>
                <th>
                    @Html.LabelFor(a => Model.First().Size)
                </th>
                <th>
                    @Html.LabelFor(a => Model.First().Price)
                </th>
                
                <th>
                    @Html.LabelFor(a => Model.First().ManufacturingDate)
                </th>        
                <th>
                    @Html.LabelFor(a => Model.First().MadeIn)
                </th>

                <th>
                    @Html.LabelFor(a => Model.First().TabletOS)
                </th>
                <th>
                    @Html.LabelFor(a => Model.First().TabletProducer)
                </th>
                <th>
                    Tác vụ
                </th>
            </tr>

        @foreach (var item in Model) {
            <tr>
                <td title="@item.Name">
                    @trimString(item.Name.ToString(), 12)
                </td>
                <td title="@item.Size">
                    @trimString(item.Size.ToString(), 5)
                </td>
                <td title="@item.Price">
                    @item.Price.ToString("#,##0")
                </td>                                
                <td title="@item.ManufacturingDate">
                    @trimString(item.ManufacturingDate.GetDateTimeFormats()[0], 10)
                </td>   
                <td title="@item.MadeIn">
                    @trimString(item.MadeIn.ToString(), 10)
                </td>  
                <td title="@item.TabletOS.Name">
                    @trimString(item.TabletOS.Name.ToString(), 10)
                </td>
                <td title="@item.TabletProducer.Name">
                    @trimString(item.TabletProducer.Name.ToString(), 10)
                </td>                
                <td>
                    @Html.ActionLink("Sửa", "Edit", new { id=item.ID }) |
                    @Html.ActionLink("Chi tiết", "Details", new { id=item.ID }) |
                    @Html.ActionLink("Xóa", "Delete", new { id=item.ID })
                </td>
            </tr>
        }

        </table>
        <div style="clear:both; height: 20px;"></div>
    